package com.contextor.magiccards.web.handlers.character.impl;

import com.contextor.magiccards.game.game.GameBattleManager;
import com.contextor.magiccards.model.character.Personage;
import com.contextor.magiccards.model.errors.MagicCardsException;
import com.contextor.magiccards.web.handlers.AbstractTOHandler;
import com.contextor.magiccards.web.handlers.character.CharacterToHandler;
import com.contextor.magiccards.web.to.user.PersonageTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * User: Sergey
 * Date: 24.04.2011 13:34:10
 */
@Service
class CharacterToHandlerImpl extends AbstractTOHandler implements CharacterToHandler {

    @Autowired
    protected GameBattleManager gameBattleManager;

    public PersonageTO loadUserCharacter(String uid) throws MagicCardsException {
        checkUid(uid);
        final Personage personage = gameBattleManager.loadPersonage(uid);
        return new PersonageTO(personage, uid);
    }
}
